<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/limh/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/limh/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/limh/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/limh/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/limh/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/limh/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/limh/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="教程,">










<meta name="description" content="程序段前缀PSP(Program Segment Prefix)是一个具有256个字节的信息区，是可执行文件(EXE和COM)所特有的，其内容在操作系统装入该文件运行时存入。  10.8.1 程序段前缀的字段含义PSP信息区的字段分布如下表10.1所列。 表10.1 PSP信息区的字段分布表 偏移量 内容含义 偏移量 内容含义 00~01H程序结束指令中断20H2E~31H保留 02~03H分配给">
<meta name="keywords" content="教程">
<meta property="og:type" content="article">
<meta property="og:title" content="10.8 程序段前缀及其应用">
<meta property="og:url" content="https://tdnr.gitee.io/limh/2015/04/01/asm50/index.html">
<meta property="og:site_name" content="土逗牛肉">
<meta property="og:description" content="程序段前缀PSP(Program Segment Prefix)是一个具有256个字节的信息区，是可执行文件(EXE和COM)所特有的，其内容在操作系统装入该文件运行时存入。  10.8.1 程序段前缀的字段含义PSP信息区的字段分布如下表10.1所列。 表10.1 PSP信息区的字段分布表 偏移量 内容含义 偏移量 内容含义 00~01H程序结束指令中断20H2E~31H保留 02~03H分配给">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-01-23T02:36:08.809Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="10.8 程序段前缀及其应用">
<meta name="twitter:description" content="程序段前缀PSP(Program Segment Prefix)是一个具有256个字节的信息区，是可执行文件(EXE和COM)所特有的，其内容在操作系统装入该文件运行时存入。  10.8.1 程序段前缀的字段含义PSP信息区的字段分布如下表10.1所列。 表10.1 PSP信息区的字段分布表 偏移量 内容含义 偏移量 内容含义 00~01H程序结束指令中断20H2E~31H保留 02~03H分配给">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/limh/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://tdnr.gitee.io/limh/2015/04/01/asm50/">





  <title>10.8 程序段前缀及其应用 | 土逗牛肉</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans ">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/limh/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">土逗牛肉</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/limh/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/limh/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/limh/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/limh/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/limh/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://tdnr.gitee.io/limh/limh/2015/04/01/asm50/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="土逗牛肉">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/limh/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="土逗牛肉">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">10.8 程序段前缀及其应用</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-04-01T20:36:15+08:00">
                2015-04-01
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/limh/categories/汇编教程/" itemprop="url" rel="index">
                    <span itemprop="name">汇编教程</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>程序段前缀PSP(Program Segment Prefix)是一个具有256个字节的信息区，是可执行文件(EXE和COM)所特有的，其内容在操作系统装入该文件运行时存入。</p>
<hr>
<h2 id="10-8-1-程序段前缀的字段含义"><a href="#10-8-1-程序段前缀的字段含义" class="headerlink" title="10.8.1 程序段前缀的字段含义"></a>10.8.1 程序段前缀的字段含义</h2><p>PSP信息区的字段分布如下表10.1所列。</p>
<p><strong>表10.1 PSP信息区的字段分布表</strong></p>
<table border="0" cellpadding="0"><tr><td>偏移量 </td><td>内容含义 </td><td>偏移量 </td><td>内容含义 </td></tr><tr><td>00~01H</td><td>程序结束指令中断20H</td><td>2E~31H</td><td>保留 </td></tr><tr><td>02~03H</td><td>分配给该程序的最后段的段地址 </td><td>32~33H</td><td>文件句柄表的长度 </td></tr><tr><td>04~09H</td><td>保留 </td><td>34~37H</td><td>指向文件句柄表的远指针 </td></tr><tr><td>0A~0DH</td><td>中断22H的地址(处理终止程序)</td><td>38~4FH</td><td>保留 </td></tr><tr><td>0E~11H</td><td>中断23H的地址(处理^Break)</td><td>50~51H</td><td>中断21H的功能调用 </td></tr><tr><td>12~15H</td><td>中断24H的地址(处理严重错误)</td><td>52~5BH</td><td>保留 </td></tr><tr><td>16~17H</td><td>保留 </td><td>5C~6BH</td><td>参数区1</td></tr><tr><td>18~2BH</td><td>缺省的文件句柄表 </td><td>6C~7FH</td><td>参数区2</td></tr><tr><td>2C~2DH</td><td>程序环境块的段地址 </td><td>80~FFH</td><td>存储缺省DTA的缓冲区 </td></tr></table>

<p>PSP信息区的字段说明：</p>
<ul>
<li>18~2BH字段：? 该字段内共有20个字节，每个字节存储一个文件句柄，所以，系统允许应用程序在某一时刻最多只能打开20个文件。</li>
</ul>
<p>前5个字节存储系统标准设备的句柄，可参阅8.3.6节——系统标准设备的句柄。</p>
<p>若某文件需要同时打开更多的文件，则需要调整文件句柄数。即：先用中断21H之功能4AH释放内存，再用其功能67H来设置新的文件句柄数。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">MOV BX, NewNum　 　　　　　　　;新的文件句柄最大数(20~65535) </span><br><span class="line"> MOV AH, 67H </span><br><span class="line"> INT 21H</span><br></pre></td></tr></table></figure>
<ul>
<li><p>2C~2DH字段： 该字段存放程序运行环境的段地址，程序的缺省运行环境有160个字节，最多可达32K。该环境含有系统命令，如：COMSPEC、PATH、PROMPT和SET。</p>
</li>
<li><p>5C~6BH字段： 该字段存放命令行的第一个参数。假设要执行下列命令：</p>
</li>
</ul>
<blockquote>
<p>Masm D:\test.asm</p>
</blockquote>
<p>这时，04H(驱动器D)、8个字符的文件名和3个字符的后缀存放在该区域，没有存放字符的单元用空格(20H)来填充。若省缺驱动器和文件名，则第一个字节为00H，其它单元为20H。</p>
<ul>
<li>6C~7FH字段： 该字段存放命令行的第二个参数。假设要执行下列命令：</li>
</ul>
<p>Masm D:\test.asm, test.obj</p>
<p>这时，test.obj作为第二参数存入该字段，存储方式如上字段。</p>
<ul>
<li>80~FFH字段： 该字段的第一个字节存放命令行参数的字符数，第二个字节为空格，从第三个字节开始存放命令行参数字符。</li>
</ul>
<h2 id="10-8-2-程序段前缀的应用"><a href="#10-8-2-程序段前缀的应用" class="headerlink" title="10.8.2 程序段前缀的应用"></a>10.8.2 程序段前缀的应用</h2><p>了解和掌握PSP中的信息分布就是为了利用其信息。对于EXE文件，可用中断21H之功能51H获取其段地址。如：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">MOV AH, 51H</span><br><span class="line"></span><br><span class="line">INT 21H ;BX=PSP的段地址 </span><br><span class="line"></span><br><span class="line">MOV ES, BX</span><br><span class="line"></span><br><span class="line">CMP byte ptr ES:[80H], 0 ;检查PSP的长度 </span><br><span class="line"></span><br><span class="line">JE next</span><br><span class="line"></span><br><span class="line">…</span><br><span class="line">对于COM文件，因为其只有一个段，所以，可用更简单的方式来检查PSP的内容。</span><br><span class="line"></span><br><span class="line">MOV BX, 80H</span><br><span class="line"></span><br><span class="line">CMP byte ptr [BX], 0 ;检查PSP的长度 </span><br><span class="line"></span><br><span class="line">JE next</span><br><span class="line"></span><br><span class="line">…</span><br></pre></td></tr></table></figure>
<p><strong>例10.17 利用PSP中的信息来终止当前程序的运行。</strong></p>
<p>解：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">        DSEG  SEGMENT</span><br><span class="line">MSG　DB　&quot;Hello$&quot; </span><br><span class="line">        DSEG  ENDS</span><br><span class="line">CSEG SEGMENT　&apos;CODE&apos; </span><br><span class="line">ASSUME　CS:CSEG, DS:DSEG </span><br><span class="line">MAIN PROC　FAR </span><br><span class="line">      start:                        ;在装入内存时，DS存放的是PSP的段地址</span><br><span class="line">              PUSH      DS</span><br><span class="line">              XOR       AX, AX</span><br><span class="line">              PUSH      AX          ;当前堆栈内容为0和PSP的段地址</span><br><span class="line">              MOV       AX, DSEG</span><br><span class="line">              MOV       DS, AX</span><br><span class="line">              MOV       DX, OFFSET MSG</span><br><span class="line">              MOV       AH, 9</span><br><span class="line">              INT       21H</span><br><span class="line">              RET</span><br><span class="line">        MAIN  ENDP</span><br><span class="line">        CSEG  ENDS</span><br><span class="line">END　start</span><br></pre></td></tr></table></figure>
<p>例10.17是早期利用PSP来终止程序的方法。子程序MAIN必须定义为FAR类型，其前三条语句是为用PSP的头二个字节来终止程序运行服务的，但现在通常用中断21H之功能4CH来终止程序的运行。</p>
<p><strong>例10.18 编写程序，显示其命令行参数信息。</strong></p>
<p>解：在使用命令行时，操作系统通常允许在被装入的程序名之后附加多达127个字符(包括最后的回车符)作为其命令的参数。</p>
<p>本例子的目的就是要了解命令行参数的存储方法，为以后使用命令行参数作准备。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"> .MODEL　SMALL </span><br><span class="line">.CODE </span><br><span class="line"> .STARTUP </span><br><span class="line">MOV AH, 51H </span><br><span class="line">INT 21H </span><br><span class="line">MOV  DS, BX ;DS=PSP的段地址 </span><br><span class="line">MOV BX, 80H </span><br><span class="line">MOV  CL, [BX] </span><br><span class="line">XOR  CH, CH </span><br><span class="line">JCXZ  over </span><br><span class="line">INC  BX ;80~FFH字段中的跳过第二个字节 </span><br><span class="line">.REPEAT </span><br><span class="line">INC</span><br><span class="line"> BX </span><br><span class="line">MOV</span><br><span class="line"> DL, [BX] </span><br><span class="line">MOV</span><br><span class="line"> AH, 2 </span><br><span class="line">INT</span><br><span class="line"> 21H </span><br><span class="line">.UNTILCXZ ;显示命令行参数中的字符 </span><br><span class="line">over: </span><br><span class="line"> .EXIT　0 </span><br><span class="line">END</span><br></pre></td></tr></table></figure>
<p><strong>例10.19 编写一个类型于DOS内部命令TYPE的程序，该命令的使用方法如下：</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">……&gt;type 文件1，文件2，…</span><br></pre></td></tr></table></figure>
<p>其功能是分别显示其参数文件1、文件2等内容，在显示文件内容前先显示文件名。显示完内容后，暂停，等待用户按任意键。若某文件不存在，则显示相应的提示信息。</p>
<p>解：为了较好地解答本题，我们可以对该问题按以下步骤来解决：</p>
<ol>
<li>若命令行参数中的字符数为0，则结束本程序的运行；</li>
<li>从命令行参数中分离出一个文件名；</li>
<li>调用子程序，显示当前文件名、文件内容和等待用户按键；</li>
<li>重复步骤1~3，直到所有参数被处理完。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br></pre></td><td class="code"><pre><span class="line"> .MODEL　SMALL, C </span><br><span class="line">.DATA </span><br><span class="line">File</span><br><span class="line"> DB　14 DUP(&apos; &apos;) </span><br><span class="line">Buff </span><br><span class="line"> DB　128 DUP(0) </span><br><span class="line">Msg1</span><br><span class="line"> DB　0DH, 0AH, &quot;$&quot; </span><br><span class="line">Msg2</span><br><span class="line"> DB　&quot;Not Found$&quot; </span><br><span class="line">Msg3</span><br><span class="line"> DB　&quot;Press any key...$&quot; </span><br><span class="line">.CODE </span><br><span class="line">;显示字符串MSG后，再进行回车、换行 </span><br><span class="line">DispStr PROC USES AX DX, MSG:PTR BYTE </span><br><span class="line"> MOV DX, MSG ;显示指定的信息  </span><br><span class="line">MOV AH, 09H </span><br><span class="line">INT 21H </span><br><span class="line">LEA DX, Msg1 ;显示回车、换行 </span><br><span class="line">MOV AH, 09H </span><br><span class="line">INT 21H </span><br><span class="line">RET </span><br><span class="line">DispStr ENDP </span><br><span class="line">;文件名的长度为传递参数Len。若文件不存在，则显示提示信息，否则，显示文件内容；</span><br><span class="line">;完成上述操作后，等待用户按键 </span><br><span class="line">Disp PROC USES AX BX CX DX, Len:BYTE </span><br><span class="line">XOR BX, BX </span><br><span class="line">MOV BL, Len </span><br><span class="line">MOV File[BX], &apos;$&apos; </span><br><span class="line">INVOKE DispStr, ADDR File ;显示文件名 </span><br><span class="line">MOV File[BX],0 </span><br><span class="line">LEA DX, File </span><br><span class="line">MOV AL, 0H </span><br><span class="line">MOV AH, 3DH </span><br><span class="line">INT 21H </span><br><span class="line">.IF CARRY? ;若创建失败，则显示失败信息 </span><br><span class="line">INVOKE　DispStr, ADDR Msg2</span><br><span class="line"> </span><br><span class="line">JMP</span><br><span class="line"> over1 </span><br><span class="line">.ENDIF </span><br><span class="line">MOV BX, AX ;参见例8.14中的有关说明 </span><br><span class="line">read: </span><br><span class="line"> LEA DX, Buff </span><br><span class="line">MOV CX, 128 </span><br><span class="line">MOV AH, 3FH </span><br><span class="line">INT 21H </span><br><span class="line">.IF CARRY? || AX==0 </span><br><span class="line">JZ</span><br><span class="line"> close </span><br><span class="line">.ENDIF </span><br><span class="line">PUSH BX </span><br><span class="line">LEA DX, Buff </span><br><span class="line">MOV CX, AX </span><br><span class="line">MOV BX, 1 </span><br><span class="line">MOV AH, 40H </span><br><span class="line">INT 21H </span><br><span class="line">POP BX </span><br><span class="line">JMP read </span><br><span class="line">close: </span><br><span class="line"> MOV AH, 3EH ;关闭已打开的文件 </span><br><span class="line">INT 21H </span><br><span class="line">over1:  </span><br><span class="line">INVOKE DispStr, ADDR Msg3 ;显示等待用户按键提示信息 </span><br><span class="line">MOV AH, 07H </span><br><span class="line">INT 21H ;等待用户按键 </span><br><span class="line">RET </span><br><span class="line">Disp ENDP </span><br><span class="line">.STARTUP </span><br><span class="line">MOV AH, 51H </span><br><span class="line">INT 21H </span><br><span class="line">MOV ES, BX </span><br><span class="line">MOV BX, 80H </span><br><span class="line">MOV CL, ES:[BX] </span><br><span class="line">DEC CL </span><br><span class="line">INC BX </span><br><span class="line">.WHILE CL&gt;0 ;CL=未被处理的参数字符数 </span><br><span class="line">XOR</span><br><span class="line"> AL, AL ;记录文件名的长度 </span><br><span class="line">LEA</span><br><span class="line"> DI, File </span><br><span class="line">.REPEAT</span><br><span class="line"> </span><br><span class="line">INC</span><br><span class="line"> BX </span><br><span class="line">MOV</span><br><span class="line"> AH, ES:[BX] </span><br><span class="line">DEC</span><br><span class="line"> CL </span><br><span class="line">.BREAK　.IF　AH==&apos;,&apos;</span><br><span class="line"> </span><br><span class="line">MOV</span><br><span class="line"> [DI], AH ;从参数中分离出字符，存入文件名中 </span><br><span class="line">INC</span><br><span class="line"> DI </span><br><span class="line">INC</span><br><span class="line"> AL </span><br><span class="line">.UNTIL</span><br><span class="line"> CL==0 </span><br><span class="line">INVOKE</span><br><span class="line"> Disp, AL ;处理当前分离出来的文件名 </span><br><span class="line">.ENDW </span><br><span class="line">.EXIT　0 </span><br><span class="line">END</span><br></pre></td></tr></table></figure>
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/limh/tags/教程/" rel="tag"># 教程</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/limh/2015/04/01/asm49/" rel="next" title="10.7 驻留程序">
                <i class="fa fa-chevron-left"></i> 10.7 驻留程序
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/limh/2015/04/01/asm51/" rel="prev" title="11.1 协处理器的数据格式">
                11.1 协处理器的数据格式 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="SOHUCS"></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/limh/images/avatar.jpg" alt="土逗牛肉">
            
              <p class="site-author-name" itemprop="name">土逗牛肉</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/limh/archives/">
              
                  <span class="site-state-item-count">255</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/limh/categories/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/limh/tags/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/limhGeek" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:1591054297@qq.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/f73b243e7cc9" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-user-circle-o"></i>简书</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#10-8-1-程序段前缀的字段含义"><span class="nav-number">1.</span> <span class="nav-text">10.8.1 程序段前缀的字段含义</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#10-8-2-程序段前缀的应用"><span class="nav-number">2.</span> <span class="nav-text">10.8.2 程序段前缀的应用</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">土逗牛肉</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
	var str = GetUrlParam('height');
    if (str === '0'){
		document.getElementById('header').style.display = 'none';
		document.getElementById('comments').style.display = 'none';
		document.getElementById('footer').style.display = 'none';
		document.getElementsByClassName('post-footer').item(0).style.display = 'none'
	}
	
    function GetUrlParam(paraName) {
        var url = document.location.toString();
        var arrObj = url.split("?");

        if (arrObj.length > 1) {
            var arrPara = arrObj[1].split("&");
            var arr;

            for (var i = 0; i < arrPara.length; i++) {
                 arr = arrPara[i].split("=");

                if (arr != null && arr[0] === paraName) {
                    return arr[1];
                }
            }
            return "";
        } else {
            return "";
        }
    }
</script>









  












  
  
    <script type="text/javascript" src="/limh/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/limh/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/limh/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/limh/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/limh/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/limh/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
